<?php
/* 
 * 点歌操作类
 * 程序编写：pennyowen/pepsi.zh
 * 联系邮箱：penyowen#gmail.com/pepsi.zh#gmail.com
 * 修改时间：2008-9-30
 */
if (!defined('IN_SITE')){ die('Hacking attempt!'); }
interface KeywordDbInter{
	### 功能：提交一个点歌记录  参数：$post 提交的内容 #####
    function submitRecord($post);
    ### 功能：删除点歌记录  参数：$id 记录id，可以是数组，也可以是当id #####
    function deleteRecord($id);
}
class keyword implements KeywordDbInter
{
	public $error = array();
	function submitRecord($var1,$type){
		global $dbconn,$dbtable;
		$var1 = acrossTrim($var1);
		$query = "select Ktimes from ".$dbtable->keyword." where Kord=$var1 and Ktype=$type limit 1";
		if (($ktime = $dbconn->Getonefield($query))){
			return $dbconn->Query_update(array('Ktimes'=>($ktime+1)),$dbtable->keyword,array('Kord'=>$var1,'Ktype'=>$type));
		}else {
			$post[Kord] = $var1;
			$post[Ktimes] = 1;
			$post[Kupdate] = date("Y-m-d H:i:s");
			$post[Ktype] = $type;
			$post[Kip] = $_SERVER[REMOTE_ADDR];
			return $dbconn->Query_adate($post,$dbtable->keyword);
		}
	}
	function deleteRecord($id){
		global $dbtable;
		if (empty($id)){ return false ;}
		if (is_array($id)){
			$where = "where Kid in(".implode(',',$id).")";
		}else {
			$where = "where Kid=$id";
		}
		return deleteRecord($dbtable->keyword,$where);
	}
}
?>